﻿using Core.Rendering;
using Core.Rendering.Enums;
using OpenTK.Mathematics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;

namespace Core.ECS.Components
{
    [DataContract]
    public class CCamera : IComponent
    {
        public Guid Id
        {
            get => _id; set => _id = value;
        }
        [DataMember]
        private Guid _id;
        [DataMember]
        public Actor Actor;
        private Camera _camera;
        public CCamera(Guid id)
        {
            _id = id;
            _camera = new Camera();
        }
        public void UpdateMatrices(CTransform transform, float width, float height)
        {
            _camera.UpdateMatrices(transform.WorldPosition, transform.WorldRotation, width, height);
        }
        [DataMember]
        public float Fov
        {
            get => _camera.Fov;
            set => _camera.Fov = value;
        }
        [DataMember]
        public float Near
        {
            get => _camera.Near;
            set => _camera.Near = value;
        }
        [DataMember]
        public float Far
        {
            get => _camera.Far;
            set => _camera.Far = value;
        }
        [DataMember]
        public Color4 ClearColor
        {
            get => _camera.ClearColor;
            set => _camera.ClearColor = new Color4(value.R, value.G, value.B, value.A);
        }
        [DataMember]
        public bool isFrustumGeometryCulling
        {
            get => _camera.IsFrustumGeometryCulling;
            set => _camera.IsFrustumGeometryCulling = value;
        }
        [DataMember]
        public bool isFrustumLightCulling
        {
            get => _camera.IsFrustumLightCulling;
            set => _camera.IsFrustumLightCulling = value;
        }
        [DataMember]
        public EProjectionMode ProjectionMode
        {
            get => _camera.ProjectionMode;
            set => _camera.ProjectionMode = value;
        }
        public Matrix4 ViewMatrix => _camera.ViewMatrix;
        public Matrix4 PerspectiveMatrix => _camera.PerspectiveMatrix;
    }
}
